﻿@model PessModel.Archive

@{
    ViewBag.Title = "CreateProposal";
    //get contact information

}

<h2>New Proposal</h2>
<br/>
<div id="operate">
    @Html.ActionLink("Back to My Proposals", "Proposals")
</div>


@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset class="create">
        <div class="heading" style="margin-top:-15px;">
            Proposal Information
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.ProjectTitle)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.ProjectTitle,new { style="width:600px;"}) *
            @Html.ValidationMessageFor(model => model.ProjectTitle)
        </div>
        <div class="editor-label">
            Track:
        </div>
        <div class ="editor-field">
            @Html.DropDownList("Tracks", "Please select a track") (Select a track first to get topics.)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model=>model.SubjectID)
        </div>
        <div class="editor-field">
            <select id="SubjectID" name="SubjectID">
                <option value="">Please select a topic</option>
            </select> *
            @Html.ValidationMessageFor(model => model.SubjectID)
            @*@Html.DropDownList("SubjectID", string.Empty)*@
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.CountyCode)
        </div>
        <div class="editor-field">
            @Html.DropDownList("CountyCode") *
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.SchoolComment)
        </div>
        <div class="editor-field" style="height:130px">
            @Html.TextAreaFor(model => model.SchoolComment, new { style = "width:600px;height:110px" })
            <div>* Words count: <span id="SchoolCommentcount"></span>/100. @Html.ValidationMessageFor(model => model.SchoolComment)</div>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CountyEBComment)
        </div>
        <div class="editor-field" style="height:250px">
            @Html.TextAreaFor(model => model.CountyEBComment, new { style = "width:600px;height:230px" })
            <div>* Words count: <span id="CountyEBCommentcount"></span>/1000. @Html.ValidationMessageFor(model => model.CountyEBComment)</div>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PrimaryKeyword)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.PrimaryKeyword,new { style="width:400px;"}) *
            @Html.ValidationMessageFor(model => model.PrimaryKeyword)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.SecondaryKeyword)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.SecondaryKeyword,new { style="width:400px;"})
            @Html.ValidationMessageFor(model => model.SecondaryKeyword)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.TechnologyRequirements)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.TechnologyRequirements,new { style="width:400px;"})
            @Html.ValidationMessageFor(model => model.TechnologyRequirements)
        </div>
        <div class="heading">
            Contact Information
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.EMail)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EMail) *
            @Html.ValidationMessageFor(model => model.EMail)
        </div>
        <div class="inline">
            <div class="editor-label">
                @Html.LabelFor(model => model.FirstName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.FirstName) *
                @Html.ValidationMessageFor(model => model.FirstName)
            </div>
        
            <div class="editor-label">
                @Html.LabelFor(model => model.LastName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.LastName) *
                @Html.ValidationMessageFor(model => model.LastName)
            </div>
        </div>

        <div class="inline">
            <div class="editor-label">
                @Html.LabelFor(model => model.PhoneNumber)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.PhoneNumber) *
                @Html.ValidationMessageFor(model => model.PhoneNumber)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.FAX)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.FAX)
                @Html.ValidationMessageFor(model => model.FAX)
            </div>
        </div>
        <div class="inline">
            <div class="editor-label">
                @Html.LabelFor(model => model.SchoolName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.SchoolName) *
                @Html.ValidationMessageFor(model => model.SchoolName)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.ProfessionalTitle)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.ProfessionalTitle)
                @Html.ValidationMessageFor(model => model.ProfessionalTitle)
            </div>
        </div>
        <div class="inline">
            <div class="editor-label">
                @Html.LabelFor(model => model.Address1)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Address1) *
                @Html.ValidationMessageFor(model => model.Address1)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Address2)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Address2)
                @Html.ValidationMessageFor(model => model.Address2)
            </div>
        </div>

        <div class="inline">
            <div class="editor-label">
                @Html.LabelFor(model => model.City)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.City) *
                @Html.ValidationMessageFor(model => model.City)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.StateProvince)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.StateProvince) *
                @Html.ValidationMessageFor(model => model.StateProvince)
            </div>
        </div>

        <div class="inline">
            <div class="editor-label">
                @Html.LabelFor(model => model.ZipCode)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.ZipCode) *
                @Html.ValidationMessageFor(model => model.ZipCode)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.Country)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Country) *
                @Html.ValidationMessageFor(model => model.Country)
            </div>
        </div>

        @Html.HiddenFor(model=>model.Gender)
        @Html.HiddenFor(model=>model.GradeLevel)

        <div class="editor-btn">
            <input type="submit" value="Create and Add Authors" />
        </div>
    </fieldset>
}


<script type="text/javascript">
    $("#Tracks").change(function (event) {
        //alert($("#Tracks").val());
        $.ajax({
            url: "@Url.Action("GetTopics", "Subject")",
            type: 'POST',
            data: { trackID: $("#Tracks").val() },
            success: function (topics) {
                $('#SubjectID').empty();                
                //$("#SubjectID").append("<option value='0'>--Select Topic--</option>");
                $.each(topics, function (i, topic) {
                    //alert(topics[i]);
                    $('<option>', { value: topic.TopicID }).html(topic.Name).appendTo($('#SubjectID'));
                });
            }
        });
    });

    function Trancuate(id, wordscount) {
        //replace multiple spaces with one space
        id = "#" + id;
        var count = $(id).val().trim().split(' ').length;
        $(id + "count").html(count);
        //if (count == wordscount)
        //    $(id).val($(id).val().trim());
        if (count >= wordscount) {
            //the better way is to find the index of the count+1 space
            $(id).val($(id).val().trim().split(' ', wordscount).join(' '));
        }
    }

    $("#SchoolComment").keyup(function (event) {//check change event
        Trancuate(this.id, 100);
    });

    $("#CountyEBComment").keyup(function (event) {
        Trancuate(this.id, 1000);
    });

    $("#SchoolComment").change(function (event) {//check change event
        Trancuate(this.id, 100);
    });

    $("#CountyEBComment").change(function (event) {
        Trancuate(this.id, 1000);
    });

    $(function () {
        var sdcount = $("#SchoolComment").val().trim().split(' ').length;
        var acount = $("#CountyEBComment").val().trim().split(' ').length;
        $("#SchoolCommentcount").html(sdcount==1?0:sdcount);
        $("#CountyEBCommentcount").html(acount==1?0:acount);
    })
</script>